package binaryTree;

/*
 *@description 相同的树
 *@author hkfan
 *@version 1.0
 *@create 2025/6/16 15:36
 */
public class LeetCode_100 {
    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode() {}
        TreeNode(int val) { this.val = val; }
        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    public boolean isSameTree(TreeNode p, TreeNode q) {
        if(p==null && q==null){
            return true;
        } else if (p!=null && q!=null) {

            return isSameTree(p.left,q.left) && isSameTree(p.right,q.right) && (p.val == q.val);

        }else {
            return false;
        }

    }

}
